<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    // 最快
    const twoSum = function(nums, target){
      let map = new Map()
      for (let i = 0; i < nums.length; i++) {
        if(map.has(target - nums[i])) {
          return [map.get(target - nums[i]), i]
        }
        map.set(nums[i], i)
      }
      return []
    }
    console.log(twoSum([2,7,11,15], 9));
    
  </script>
</body>
</html>